package com.test.util;

import java.util.Random;

/**
 * 自定义的盐的工具类
 */
public class saltUtils {
    public static String getSaltUtils(int n) {
        //定义随机盐的组成
        char[] salts = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789!@#$%^&*".toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char salt = salts[new Random().nextInt(salts.length)];
            stringBuilder.append(salt);
        }
        return stringBuilder.toString();
    }

    //获取随机盐测试
    public static void main(String[] args) {
        System.out.println(getSaltUtils(5));
    }
}
